#include<iostream>
#include<fstream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l>=n){
		cout<<n-1;
	}
	else{
		cout<<r%n;
	}
	return 0;
}
